public class Test {
    public static void fun(int n,char a,char b,char c) {
        if(n == 1) {
            System.out.print(a+"->"+c+" ");
        }else {
            fun(n-1,a,c,b);
            System.out.print(a+"->"+c+" ");
            fun(n-1,b,a,c);
        }
    }

    public static void main(String[] args) {
        char a = 'a';
        char b = 'b';
        char c = 'c';
        fun(4,a,b,c);
        System.out.println();
    }
}
